package com.ruoyi.system.controller.front;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.ruoyi.system.controller.CxBase;
import com.ruoyi.system.domain.StudentInfo;
import com.ruoyi.system.domain.front.FrontUserInfo;
import com.ruoyi.system.service.front.ISafetyExaminationFrontService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 案件信息Controller
 *
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/front/safetyexaminationfront")
public class SafetyExaminationFrontController extends CxBase {
    @Autowired
    private ISafetyExaminationFrontService safetyExaminationFrontService;

    /**
     * 查询安全考试信息
     */

    @GetMapping("/selectexaminationinfo")
    public TableDataInfo selectexaminationinfo(StudentInfo studentInfo)
    {
        logput(studentInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(safetyExaminationFrontService.selectexaminationinfo(studentInfo));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }
    /**
     * 查询学生考试题目和统计记录
     */
    @GetMapping("/selectExaminationFront")
    public TableDataInfo selectExaminationFront(FrontUserInfo frontUserInfo)
    {
        logput(frontUserInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        frontUserInfo.setPaperId(safetyExaminationFrontService.selectStudentExaminationRecord(frontUserInfo));
        TableDataInfo tableDataInfo = getDataTable(safetyExaminationFrontService.selectExaminationFrontContent(frontUserInfo));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 保存学生考试信息
     */
    @Transactional
    @PostMapping("/saveExamination")
    public TableDataInfo saveExamination(@RequestBody FrontUserInfo frontUserInfo)
    {
        logput(frontUserInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        safetyExaminationFrontService.saveExamination(frontUserInfo);
        TableDataInfo tableDataInfo = getDataTable(200,"操作成功");
        return tableDataInfo;
    }

    /**
     * 学生成绩统计
     */
    @GetMapping("/selectExaminationFrontResult")
    public TableDataInfo selectExaminationFrontResult(FrontUserInfo frontUserInfo)
    {
        logput(frontUserInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(safetyExaminationFrontService.selectExaminationFrontResult(frontUserInfo));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }

    /**
     * 抽奖
     */
    @Transactional
    @GetMapping("/luckDraw")
    public TableDataInfo luckDraw(FrontUserInfo frontUserInfo)
    {
        logput(frontUserInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        TableDataInfo tableDataInfo = getDataTable(safetyExaminationFrontService.luckDraw(frontUserInfo));
        logout(tableDataInfo,Thread.currentThread().getStackTrace()[1].getMethodName(),this.getClass());
        return tableDataInfo;
    }


}
